/** layui-v0.0.7 跨设备模块化前端框架@LGPL www.layui.com By 贤心 */
; !
function(e) {
    var t = function() {
        this.v = "0.0.7"
    };
    t.fn = t.prototype;
    var o = document,
    n = {},
    r = t.fn.cache = {},
    l = function() {
        var e = o.scripts,
        t = e[e.length - 1].src;
        return t.substring(0, t.lastIndexOf("/") + 1)
    } (),
    i = function(t) {
        e.console && console.error && console.error("layui Error: " + t)
    },
    u = "undefined" != typeof opera && "[object Opera]" === opera.toString();
    r.device = "pc",
    r.modules = {},
    r.status = {},
    r.timeout = 10,
    t.fn.define = function(e, t) {
        var o = this,
        n = "function" == typeof e;
        return n && (t = e),
        o.use(n ? [] : e,
        function() {
            "function" == typeof t && t(function(e, t) {
                layui[e] = t,
                r.status[e] = !0
            })
        }),
        o
    },
    t.fn.use = function(e, t, a) {
        function s(e, t) {
            var o = "PLAYSTATION 3" === navigator.platform ? /^complete$/: /^(complete|loaded)$/; ("load" === e.type || o.test((e.currentTarget || e.srcElement).readyState)) && (r.modules[p] = t, m.removeChild(v),
            function n() {
                return++y > 1e3 * r.timeout / 4 ? i(p + " is not a valid module") : void(r.status[p] ? c() : setTimeout(n, 4))
            } ())
        }
        function c() {
            a.push(layui[p]),
            e.length > 1 ? d.use(e.slice(1), t, a) : "function" == typeof t && t.apply(layui, a)
        }
        var d = this,
        f = r.dir = r.dir ? r.dir: l,
        m = o.getElementsByTagName("head")[0];
        e = "string" == typeof e ? [e] : e;
        var p = e[0],
        y = 0;
        if (a = a || [], r.host = r.host || (f.match(/\/\/([\s\S]+?)\//) || ["//" + location.host + "/"])[0], 0 === e.length) return t();
        var v = o.createElement("script"),
        g = (n.modules[p] ? f + "lay/": r.base || "") + (d.modules[p] || p) + ".js";
        return v.async = !0,
        v.src = g + "?v=" +
        function() {
            return r.version === !0 ? r.v || (new Date).getTime() : r.version || ""
        } (),
        r.modules[p] ? !
        function h() {
            return++y > 1e3 * r.timeout / 4 ? i(p + " is not a valid module") : void("string" == typeof r.modules[p] && r.status[p] ? c() : setTimeout(h, 4))
        } () : (m.appendChild(v), !v.attachEvent || v.attachEvent.toString && v.attachEvent.toString().indexOf("[native code") < 0 || u ? v.addEventListener("load",
        function(e) {
            s(e, g)
        },
        !1) : v.attachEvent("onreadystatechange",
        function(e) {
            s(e, g)
        })),
        r.modules[p] = g,
        d
    },
    t.fn.all = function(e) {
        var t = this,
        o = Object.keys ? Object.keys(t.modules) : function() {
            var e = [];
            for (var o in t.modules) e.push(o);
            return e
        } ();
        return layui.use(o, e),
        t
    },
    t.fn.getStyle = function(t, o) {
        var n = t.currentStyle ? t.currentStyle: e.getComputedStyle(t, null);
        return n[n.getPropertyValue ? "getPropertyValue": "getAttribute"](o)
    },
    t.fn.link = function(e, t, n) {
        var l = this,
        u = o.createElement("link"),
        a = o.getElementsByTagName("head")[0];
        "string" == typeof t && (n = t);
        var s = (n || e).replace(/\.|\//g, ""),
        c = u.id = "layuicss-" + s,
        d = 0;
        u.rel = "stylesheet",
        u.href = e + (r.debug ? "?v=" + (new Date).getTime() : ""),
        u.media = "all",
        o.getElementById(c) || a.appendChild(u),
        "function" == typeof t && !
        function f() {
            return++d > 1e3 * r.timeout / 100 ? i(e + " timeout") : void(1989 === parseInt(l.getStyle(o.getElementById(c), "width")) ?
            function() {
                t()
            } () : setTimeout(f, 100))
        } ()
    },
    t.fn.addcss = function(e, t, o) {
        layui.link(r.dir + "css/" + e, t, o)
    },
    t.fn.router = function(e) {
        for (var t, o = (e || location.hash).replace(/^#/, "").split("/") || [], n = {
            dir: []
        },
        r = 0; r < o.length; r++) t = o[r].split("="),
        /^\w+=/.test(o[r]) ?
        function() {
            "dir" !== t[0] && (n[t[0]] = t[1])
        } () : n.dir.push(o[r]),
        t = null;
        return n
    },
    t.fn.img = function(e, t, o) {
        var n = new Image;
        return n.src = e,
        n.complete ? t(n) : (n.onload = function() {
            n.onload = null,
            t(n)
        },
        void(n.onerror = function(e) {
            n.onerror = null,
            o(e)
        }))
    },
    t.fn.data = function(e, t) {
        if (e = e || "layui", t = "object" == typeof t ? t: {
            key: t
        },
        window.JSON && window.JSON.parse) {
            try {
                var o = JSON.parse(localStorage[e])
            } catch(n) {
                var o = {}
            }
            return t.value && (o[t.key] = t.value),
            t.remove && delete o[t.key],
            localStorage[e] = JSON.stringify(o),
            t.key ? o[t.key] : o
        }
    },
    t.fn.each = function(e, t) {
        if ("function" == typeof t) if (e = e || [], e.constructor === Array) for (var o = 0; o < e.length && !t(o, e[o]); o++);
        else if (e.constructor === Object) for (var n in e) if (t(n, e[n])) break
    },
    t.fn.config = function(e) {
        e = e || {};
        for (var t in e) r[t] = e[t];
        return this
    },
    n.modules = {
        laytpl: "lib/laytpl",
        laypage: "lib/laypage",
        socket: "lib/socket",
        terminal: {
            pc: {
                jquery: "pc/lib/jquery",
                layout: "pc/modules/layout",
                layer: "pc/modules/layer",
                laydate: "pc/modules/laydate",
                layim: "pc/modules/layim",
                tree: "pc/modules/tree",
                slide: "pc/modules/slide",
                editor: "pc/modules/editor",
                table: "pc/modules/table",
                flow: "pc/modules/flow",
                util: "pc/modules/util",
                form: "pc/modules/form",
                code: "pc/modules/code",
                upload: "pc/modules/upload",
                single: "pc/modules/single"
            },
            mobile: {
                zepto: "mobile/lib/zepto",
                layer: "mobile/modules/layer",
                util: "mobile/modules/util",
                ui: "mobile/modules/ui",
                form: "mobile/modules/form",
                debug: "mobile/modules/debug"
            }
        }
    },
    t.fn.modules = function() {
        var e = {};
        for (var t in n.modules) if ("terminal" === t) {
            var o = n.modules.terminal[r.device];
            for (var l in o) e[l] = o[l],
            n.modules[l] = o[l];
            delete n.modules.terminal
        } else e[t] = n.modules[t];
        return e
    } (),
    t.fn.extend = function(e) {
        var t = this;
        e = e || {};
        for (var o in e) t[o] || t.modules[o] ? i("模块名 " + o + " 已被占用") : t.modules[o] = e[o];
        return t
    },
    e.layui = new t
} (window);